package com.zone.core.base

import android.os.Bundle
import android.view.LayoutInflater
import androidx.databinding.ViewDataBinding

/**
 *Author: last
 *Time: 2019-09-03
 *Description: xxx
 */
abstract class BaseBindingActivity<BINDING : ViewDataBinding> : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = createDataBinding()
        binding.lifecycleOwner = this
        setContentView(binding.root)
        initDataBinding(binding)
    }

    private fun createDataBinding(): BINDING {
        return getBindingType(javaClass)
            ?.getMethod("inflate", LayoutInflater::class.java)
            ?.invoke(null, LayoutInflater.from(this)) as BINDING
    }

    open fun initDataBinding(binding: BINDING){
        
    }

}